home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-6.dms / in.adf / Install.run / GOLDEDDATA / developer / examples / scanner / source / guide.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-30  |  2.3 KB  |  86 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   COPYIGHT
  4.  
  5.   ©1995  Dietmar  Eilert  (e-mail:  DIETMAR@TOMATE.TNG.OCHE.DE).  All  Rights
  6.   Reserved.  Code  may not be reused/reproduced without written permission of
  7.   the author.
  8.  
  9.   Dietmar Eilert
  10.   Mies-v-d-Rohe-Str.31, 52074 Aachen, Germany
  11.   E-Mail: DIETMAR@TOMATE.TNG.OCHE.DE
  12.   Tel: +49-(0)241-81665
  13.        +49-(0)2525-7776
  14.   Fax: +49-(0)241-81665
  15.  
  16.   Example: scan handler looking for AmigaGuide nodes (DICE-C). Scan handlers are 
  17.   plain functions loadSeg'ed by GED: no standard C startup code and no library
  18.   calls.
  19.  
  20.   DICE C (-ms1 makes DICE compiler put string constants into code hunk):
  21.   
  22.   dcc guide.c -// -l0 -md -ms1 -mRR -o ram:guide
  23.  
  24.   ------------------------------------------------------------------------------
  25. */
  26.  
  27. #include <exec/types.h>
  28.  
  29. #define UPPER(a) ((a) & 95)
  30.  
  31. ULONG
  32. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  33. {
  34.     const char *version = "$VER: Guides 1.3 (" __COMMODORE_DATE__ ")";
  35.  
  36.     if (**text == '@') {
  37.  
  38.         if (len > 4) {
  39.  
  40.             UBYTE *next = *text + 1;
  41.  
  42.             if (UPPER(*next++) == 'N') {
  43.  
  44.                 if (UPPER(*next++) == 'O') {
  45.  
  46.                     if (UPPER(*next++) == 'D') {
  47.  
  48.                         if (UPPER(*next++) == 'E') {
  49.  
  50.                             UWORD letters = 0;
  51.  
  52.                             for (len -= 5; len; --len) {
  53.  
  54.                                 if (*next == '"') {
  55.  
  56.                                     for (*text = ++next, --len; len && (*next != '"'); ++next)
  57.                                         ++letters;
  58.  
  59.                                     return(letters);
  60.                                 }
  61.                                 else if (*next == ' ')
  62.  
  63.                                     next++;
  64.  
  65.                                 else {
  66.  
  67.                                     for (*text = next; len-- && (*next != ' ') && (*next != '"'); ++next)
  68.                                         ++letters;
  69.  
  70.                                     return(letters);
  71.                                 }
  72.                             }
  73.  
  74.                             *text = "(unnamed)";
  75.  
  76.                             return(9);
  77.                         }
  78.                     }
  79.                 }
  80.             }
  81.         }
  82.     }
  83.  
  84.     return(FALSE);
  85. }
  86.